package com.zp.qualitypractice;

import android.app.Application;
import android.graphics.Point;
import android.view.WindowManager;

/**
 * Created by izp on 2017/7/27.
 */

public class FitApp extends Application {
    public final static float DESIGN_WIDTH_PX = 750;//px
    public final static float DESIGN_WIDTH_DP = 375;//dp
    public void fitScreen(){
        Point size = new Point();//用一个点来表示宽高，
        ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getSize(size);
//        这样size中就保存了宽高信息
        getResources().getDisplayMetrics().xdpi = size.x/ DESIGN_WIDTH_PX *72f;
//        getResources().getDisplayMetrics().ydpi
//        getResources().getDisplayMetrics().density
//        pt（磅）：1/72英寸。
    }
}
